package com.oauth.google.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.oauth.auth.client.beans.MemberClientBean;
import com.oauth.auth.client.rpc.MemberRemoteService;
import com.oauth.auth.client.rpc.MemberRemoteServiceAsync;
import com.oauth.components.client.rpc.OAuthAsnyCallBack;
import com.oauth.components.client.ui.footer.FooterUI;
import com.oauth.components.client.ui.header.HeaderUI;
import com.oauth.google.client.ui.GoogleTabPanel;

public class LocalEntryPoint implements EntryPoint {

	private final MemberRemoteServiceAsync memberService = GWT.create(MemberRemoteService.class);

	private static GoogleEntryPointUiBinder uiBinder = GWT.create(GoogleEntryPointUiBinder.class);

	interface GoogleEntryPointUiBinder extends UiBinder<DockLayoutPanel, LocalEntryPoint> {
	}

	@UiField
	HeaderUI header;

	@UiField
	FooterUI footer;

	@UiField
	GoogleTabPanel googleTabPanel;

	@UiField
	VerticalPanel westPanel;

	public void onModuleLoad() {
		DockLayoutPanel p = uiBinder.createAndBindUi(this);

		// header.getLoadingLabel().setText("loading...");
		memberService.getMember(new OAuthAsnyCallBack<MemberClientBean>() {
			public void onSuccess(MemberClientBean result) {
				header.setUserName(result.getEmail());
			}
		});

		googleTabPanel.initTabPanel();

		RootLayoutPanel rp = RootLayoutPanel.get();
		rp.add(p);
		// RootPanel.get().add(dockPanel);
	}

}